<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<style>
input {width:150px;}
.wrapContent {margin:0 auto;padding:0 30px;}
.center {text-align:center;}
.block {padding:10px 30px;}
.line {border:none;border-bottom:1px solid #666;clear:both;}
.lineHeight{height:34px;line-height:34px;}
.right {text-align:right;width:120px;vertical-align:top}
.errMsg {color:red;margin:0 0 0 5px;}
</style>
</head>
<body>
<div class="wrapContent">
	<div class="block">
		<h2 class="center">修改用户信息</h2>
		<table style="width:500px;border:none;margin:50px auto 0;" cellpadding="0" cellspacing="0">
			<tr class="lineHeight">
				<td class="right">用户类型：</td>
				<td>
					<select id="type">
					<?php
						foreach($conf['level'] as $value=>$name){
							$selected = ($value == $userInfo['level']) ? 'selected="selected"' : '';
							echo "<option value='{$value}' {$selected}>{$name}</option>";
						}
					?>
					</select>
					<b id="addressErrMsg" class="errMsg">*</b>
				</td>
			</tr>
			<tr class="lineHeight">
				<td class="right">用户名：</td>
				<td><input id="username" value="<?php echo $userInfo['username']; ?>" disabled/><b id="usernameErrMsg" class="errMsg">*</b></td>
			</tr>
			<tr class="lineHeight">
				<td class="right">备注：</td>
				<td><textarea id="remark" cols="40" rows="5"><?php echo $userInfo['remark']; ?></textarea><b id="remarkErrMsg" class="errMsg"></b></td>
			</tr>
		</table>
	</div>
	<div class="center">
		<input id="uid" type="hidden" value="<?php echo $userInfo['id']; ?>"/>
		<input id="submit" type="button" class="submitBtn" value="修改"/>
	</div>
</div>
</body>
<script src="/js/lib.min.js" type="text/javascript"></script>
<script src="/js/md5.min.js" type="text/javascript"></script>
<script type="text/javascript">
function getUserType() {
	var obj = $('#type')[0];
	return obj.options[obj.selectedIndex].value;
}
var uid = $('#uid').val(),
	remarkInput = $('#remark'),
	remarkErrMsg = $('#remarkErrMsg'),
	submitBtn = $('#submit');
	
submitBtn.attr({onclick:function(){
	var type = getUserType(),
		remark = $.trim(remarkInput.val());
	
	submitBtn.val('正在处理，请稍后...');
	submitBtn[0].disabled = true;
	
	$.ajax({
		url:'/admin/user.php?op=doModify',
		data:{'level':type, 'id':uid, 'remark':remark},
		type:'POST',
		callback:function(res){
			alert(res.errmsg);
			submitBtn.val('确定');
			submitBtn[0].disabled = false;
			if (res.errno == '0'){
				location.href='/admin/user.php?op=manage';
			}
		}
	});
}});
</script>
</html>